#ifndef RENDER2D_H
#define RENDER2D_H

#include <QtGui>
#include <vector>
#include "mathbox.h"

struct ShipViewElement
{
	ShipViewElement(const QPainterPath& path, const QBrush& brush, const QPen& pen)
		: path(path)
		, brush(brush)
		, pen(pen)
	{}
	QPainterPath path;
	QBrush brush;
	QPen pen;
};

class Render2D : public QWidget
{
	Q_OBJECT

public:
	Render2D(QWidget *parent = 0);
	~Render2D();
	QSize minimumSizeHint() const;
    QSize sizeHint() const;
	int heightForWidth (int w) const;

public slots:
     void setShipRenderData(const ShipRenderData& shipRenderData);
	 void traceStateChanged(int state);

protected:
    void paintEvent(QPaintEvent *event);
	void timerEvent(QTimerEvent *event);
	void wheelEvent(QWheelEvent *event);
	void mousePressEvent(QMouseEvent *e);
	void mouseMoveEvent(QMouseEvent *e);

private:
	void drawShip(QPainter& painter);
	void drawPrint(QPainter& painter);

private:
	std::vector<ShipViewElement> shipView;
	ShipRenderData shipRenderData;
	QList<ShipRenderData> shipPrints;
	int printsNum;
	double printsDT;
	double scaleFactor;
	QPoint lastViewPos;
	QPointF viewPos;
	bool traceShip;
};

#endif // RENDER2D_H
